/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataObject;

import java.io.Serializable;
import java.util.Vector;
import org.w3c.dom.Element;

/**
 *
 * @author MinhNhat
 */
public class MyRowData implements Serializable {

    public Vector Datas;

    public MyRowData() {
        Datas = new Vector();
    }
    
    public MyRowData(Element ele, Vector Headers)
    {
        Datas = new Vector();
        for(int i= 0;i<Headers.size();i++)
        {
            MyColumn Column = (MyColumn)Headers.get(i);
            MyData Data = new MyData(Column,ele.getAttribute(Column.Name));
            Datas.add(Data);
        }
    }
    
    public MyData GetData(String str)
    {
        for(int i=0;i<Datas.size();i++)
        {
            MyData data = (MyData)Datas.get(i);
            if(data.Column.compareTo(str)==0)
            {
                return data;
            }
        }
        return null;
    }
    
    public boolean hasColumn(String str)
    {
        MyData data = this.GetData(str);
        if(data!=null)
        {
            return true;
        }
        return false;
    }

    public void Print() {
        for (int i = 0; i < Datas.size(); i++) {
            MyData row = (MyData) Datas.get(i);
            row.Print();
        }
        System.out.println("");
    }
    
    public boolean isEqual(TableObject tableObject)
    {
        for(int i=0;i<Datas.size();i++)
        {
            MyData data = (MyData)Datas.get(i);
            if(data.Value.compareTo(tableObject.getAttributeAt(data.id).toString())!=0)
            {
                return false;
            }       
        }
        return true;
    }
}
